function bits = entropm(x);
% Stat. development and entropy computation
% x should be integer matrix
if ~isempty(x),
 x=round(x);
 [m,n]=size(x);
 mini=min(min(x));
 maxi=max(max(x));
 for i=mini:maxi
   y(i-mini+1)=sum(sum(x==i));
 end;
 y=y/n/m;
 en=-sum(y.*log(y+(y==zeros)))/log(2);
 bits=en*m*n;
else
% disp('empty input'); pause
 en=0; bits=0;
end;

